<template>
  <div class="viewFramework-product-navbar-collapse ng-scope rotate270" :style="navbarStyle" @click="collapseProductNavbar($event)">
    <div class="product-navbar-collapse-inner">
      <div class="product-navbar-collapse-bg"></div>
      <div class="product-navbar-collapse">
        <span class="icon-collapse-left  fa fa-dedent fa-fw" style="display: none;"></span>
        <span class="icon-collapse-right fa fa-fw fa-indent" style="display: inline;"></span>
      </div>
    </div>
  </div>
</template>
<script>
  import $ from 'jquery'
  export default{
    props: ['height'],
    data(){
      return {
        navbarStyle: {}
      }
    },
    mounted(){
      this.navbarStyle = {
        top: -34 + "px"
      }
    },
    methods: {
      collapseProductNavbar: function (event) {
        const e = event.currentTarget;
        const $this = $(e);
        if ($this.find(".product-navbar-collapse-bg-right").length > 0) {
          $this.find(".product-navbar-collapse-bg-right").removeClass("product-navbar-collapse-bg-right").addClass("product-navbar-collapse-bg");
          $this.find(".product-navbar-collapse-right").removeClass("product-navbar-collapse-right").addClass("product-navbar-collapse");
          $this.find(".icon-collapse-left").css("display", "none");
          $this.find(".icon-collapse-right").css("display", "inline");
          $this.css("top", -34 + "px");
          $this.prev().show();
          $this.prev().animate({height: this.height}, "fast");
          this.$emit('tableHeightChange', -this.height)
        } else {
          $this.find(".product-navbar-collapse-bg").removeClass("product-navbar-collapse-bg").addClass("product-navbar-collapse-bg-right");
          $this.find(".product-navbar-collapse").removeClass("product-navbar-collapse").addClass("product-navbar-collapse-right");
          $this.find(".icon-collapse-left").css("display", "inline");
          $this.find(".icon-collapse-right").css("display", "none");
          $this.css("top", -15 + "px");
          $this.prev().animate({height: 0}, "fast", function () {
            $this.prev().hide();
          });
          this.$emit('tableHeightChange', this.height)
        }
      }
    }
  }
</script>
<style scoped>
  .viewFramework-product-navbar-collapse {
    position: relative;
    left: 50%;
    width: 20px;
    height: 50px;
    z-index: 3;
    -o-transition: all 0.2s ease;
    -ms-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -webkit-transition: all 0.2s ease
  }

  .viewFramework-product-navbar-collapse:hover .product-navbar-collapse {
    left: 0
  }

  .viewFramework-product-navbar-collapse:hover .product-navbar-collapse-right {
    right: 0
  }

  .viewFramework-product-navbar-collapse:hover .product-navbar-collapse-bg {
    border-bottom: 8px solid transparent;
    border-left: 20px solid #D9DEE4;
    border-top: 8px solid transparent
  }

  .viewFramework-product-navbar-collapse:hover .product-navbar-collapse-bg-right {
    border-bottom: 8px solid transparent;
    border-right: 20px solid #D9DEE4;
    border-top: 8px solid transparent
  }

  .viewFramework-product-navbar-collapse .product-navbar-collapse-inner {
    top: -50%;
    position: relative;
    overflow: hidden
  }

  .viewFramework-product-navbar-collapse .product-navbar-collapse {
    height: 50px;
    position: relative;
    left: -7px;
    text-align: center;
    cursor: pointer;
    -o-transition: all 0.1s ease, 0.1s ease;
    -ms-transition: all 0.1s ease, 0.1s ease;
    -moz-transition: all 0.1s ease, 0.1s ease;
    -webkit-transition: all 0.1s ease, 0.1s ease
  }

  .viewFramework-product-navbar-collapse .product-navbar-collapse-right {
    height: 50px;
    position: relative;
    right: -7px;
    text-align: center;
    cursor: pointer;
    -o-transition: all 0.1s ease, 0.1s ease;
    -ms-transition: all 0.1s ease, 0.1s ease;
    -moz-transition: all 0.1s ease, 0.1s ease;
    -webkit-transition: all 0.1s ease, 0.1s ease
  }

  .viewFramework-product-navbar-collapse .product-navbar-collapse > span, .product-navbar-collapse-right > span {
    font-size: 15px;
    line-height: 50px;
    vertical-align: text-top
  }

  .viewFramework-product-navbar-collapse .product-navbar-collapse-bg {
    width: 0;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    border-bottom: 9px solid transparent;
    border-left: 13px solid #D9DEE4;
    border-top: 9px solid transparent;
    -o-transition: all 0.1s ease, 0.1s ease;
    -ms-transition: all 0.1s ease, 0.1s ease;
    -moz-transition: all 0.1s ease, 0.1s ease;
    -webkit-transition: all 0.1s ease, 0.1s ease
  }

  /* #f7f7f7 */
  .viewFramework-product-navbar-collapse .product-navbar-collapse-bg-right {
    width: 0;
    height: 50px;
    position: absolute;
    top: 0;
    left: auto;
    right: 0;
    border-bottom: 9px solid transparent;
    border-right: 13px solid #D9DEE4;
    border-top: 9px solid transparent;
    -o-transition: all 0.1s ease, 0.1s ease;
    -ms-transition: all 0.1s ease, 0.1s ease;
    -moz-transition: all 0.1s ease, 0.1s ease;
    -webkit-transition: all 0.1s ease, 0.1s ease
  }

  .viewFramework-product-navbar-collapse .icon-collapse-left {
    display: inline
  }

  .viewFramework-product-navbar-collapse .icon-collapse-right {
    display: none
  }

  .rotate270 {
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    -moz-transform: rotate(270deg);
    -o-transform: rotate(270deg);
    -webkit-transform: rotate(270deg);
    transform: rotate(270deg);
  }
</style>
